function[xgir,angulo2]=girar(xbin,angulo)
[m,n]=size(xbin); 
[f,c]=find(xbin(:,:)==0);
%xgir=ones(m,n);
%xgir2=xgir;
if angulo<=0
   angulo2=90+(angulo);
else
   angulo2=90-angulo;
end
for i=1:length(f)
  
        a(i)=round(c(i)-(f(i)/tan(angulo2)));
end
if min(a)<0
    xgir=ones(m,(n+(abs(min(a)))));
elseif min(a)==0
    xgir=ones(m,(n+1));
else
    xgir=ones(m,n);
end
if max(a)>n
    xgir=ones(m,(n+(max(a)-n)));
elseif (max(a)<n)&&(min(a)<0)
    xgir=ones(m,(n+(abs(min(a)))+(max(a)-n)));
end
%b=a;
%b(find(a<=a(1)))=a(1);
for i=1:length(f)
   if (min(a)<0)
        %xgir(f(i),(c(1)+(a(i))))=xbin(f(i),c(i));
   %else
        xgir(f(i),(a(i)+abs(min(a)))+1)=xbin(f(i),c(i));
   elseif (min(a)>=0)&&(a(i)==0)
        xgir(f(i),1)=xbin(f(i),c(i));
   else
        xgir(f(i),a(i))=xbin(f(i),c(i));
   end
end
%[ff,cc]=find(xgir==0);
%[ff1,cc1]=find(xgir2==0);
%largo=(n-min(cc1))+(max(cc)-min(cc)+2);
%xresul=ones(m,largo);
%xresul(:,2:(max(cc)-min(cc)+2))=xgir(:,[min(cc):max(cc)]);
%xresul(:,[(max(cc)-min(cc))+2:largo])=xgir2(:,[min(cc1):n]);
%figure;
%imshow(xgir);
figure;
imshow(xgir);
%figure
%imshow(xresul);